home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_07 / barbu / wengine.hpp < prev   
Encoding:
C/C++ Source or Header  |  1995-03-17  |  1.8 KB  |  77 lines

  1. article\Listing5
  2.  
  3. /////////////////////////////////////////////////////
  4. //    WENGINE + WSYM Implementation
  5. /////////////////////////////////////////////////////
  6. #include "WENGINE.HPP"
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9.  
  10. WSYM::WSYM(const char szApp[], const char szSect[])
  11.         : SYM(), _name(szApp),
  12.         _sect(szSect ? szSect : "DEFAULT")
  13. {
  14. _name += ".INI";
  15. }
  16.  
  17. int WSYM::get(const char szSym[])
  18. {
  19. return GetPrivateProfileInt(_sect, szSym, 0, _name);
  20. }
  21.  
  22. void WSYM::set(const char szSym[], int nNumValue)
  23. {
  24. char Buff[16];
  25. itoa(nNumValue, Buff, 10);
  26. WritePrivateProfileString(_sect, szSym, Buff, _name);
  27. }
  28.  
  29.  
  30. WENGINE::WENGINE(const char szHppTemplate[],
  31.         const char szCppTemplate[], HWND hWnd)
  32.     : ENGINE(szHppTemplate, szCppTemplate)
  33. {
  34. _hWnd = hWnd;
  35. }
  36.  
  37. void WENGINE::cannotOpen(const char szFile[])
  38. {
  39. MessageBox(_hWnd, "Unable to open file", szFile,
  40.             MB_ICONSTOP | MB_OK);
  41. }
  42.  
  43. int WENGINE::overwriteQuest(const char szFile[])
  44. {
  45. return IDYES == MessageBox(_hWnd,
  46.         "File already exists, overwrite?",
  47.         szFile, MB_ICONQUESTION | MB_YESNO);
  48. }
  49.  
  50. void WENGINE::unexpectedEOB(const char szFile[],
  51.                     int nLine)
  52. {
  53. _errorEOB("Unbalanced", szFile, nLine);
  54. }
  55.  
  56. void WENGINE::missingEOB(const char szFile[],
  57.                     int nLine)
  58. {
  59. _errorEOB("Missing", szFile, nLine);
  60. }
  61.  
  62. void WENGINE::_errorEOB(const char szMsg[],
  63.                     const char szFile[], int nLine)
  64. {
  65. STR s(256);
  66. sprintf((char*)(const char*)s,
  67.     "%s \"%s\", line %d", szMsg, _FlagOff, nLine);
  68. MessageBox(_hWnd, s, szFile, MB_ICONSTOP | MB_OK);
  69. }
  70.  
  71. void WENGINE::runEditor(const char szFile[])
  72. {
  73. char szCmd[256];
  74. WinExec(strcat(strcpy(szCmd, "NOTEPAD.EXE "), szFile),
  75.         SW_SHOWNORMAL);
  76. }
  77.